<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
<meta name="description" content="">
<meta name="author" content="">

<title>选择商品</title>

<!-- Bootstrap core CSS -->
<link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet">

<!-- Custom styles for this template -->
<link href="<%=basePath%>css/designer.css" rel="stylesheet">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    
<script type="text/javascript" src="<%=basePath%>js/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
	$(function(){
		$("#catalogId").change(function(){
			$("#searchForm1").submit();
		});
	})
	
	function addToCar(pid) {
		window.showModalDialog("/designer/addToCar?pid=" + pid, "", "dialogWidth:550px; dialogHeight:500px; status:0; help:0");
	}
</script>

</head>

<body>
  <script type="text/javascript" src="<%=basePath%>js/wz_tooltip.js"></script>
  <div class="container">
    <div class="row">
      <div class="panel panel-primary">
        <div class="panel-heading">检索条件</div>
        <div class="panel-body">
          <form id="searchForm1" action="/designer/chooseProduct" method="post">
            <div class="col-md-4">
              <label>主材类别</label>
              <div class="form-group">
                <select id="catalogId" name="catalogId">
                  <c:forEach items="${catalogList }" var="option" varStatus="s">
                    <c:if test="${option.id == catalogId }">
                      <option value="${option.id }" selected="selected">${option.name }</option>
                    </c:if>
                    <c:if test="${option.id != catalogId }">
                      <option value="${option.id }">${option.name }</option>
                    </c:if>
                  </c:forEach>
                </select>
              </div>
          </div>
          <div class="col-md-4">
              <label>商品型号</label>
              <div class="form-group">
                <input type="text" class="input-sm form-control" name="type" value="${type }">
              </div>
              <button type="submit" class="btn btn-sm btn-info">搜索</button>
          </div>
          </form>
          <div class="col-md-2 col-md-offset-2">
            <a class="btn btn-success" href="/designer/showCar"><span class="glyphicon glyphicon-shopping-cart" aria-hidden="true"></span>&nbsp;去购物车结算</a>
          </div>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="panel panel-primary">
        <div class="panel-heading">商品列表</div>
        <div class="panel-body">
          <table class="table table-bordered table-striped">
            <thead>
              <tr>
                <th>状态</th>
                <c:if test="${catalogId == 9 }">
                  <th>名称</th>
                </c:if>
                <c:if test="${catalogId != 9 }">
                  <th>图片</th>
                  <th>品牌</th>
                  <th>型号</th>
                  <th>规格</th>
                  <th>材质</th>
                </c:if>
                <th>单位</th>
                <c:if test="${sessionScope.xlf_planType == '4' }">
                  <th>价格</th>
                </c:if>
                <th>备注</th>
                <th>操作</th>
              </tr>
            </thead>
            <tbody>
              <c:forEach items="${pageRecord.list }"  var="p" varStatus="s">
                <c:if test="${p.status == 1 }">
                  <tr>
                </c:if>
                <c:if test="${p.status == 0 }">
                  <tr class="danger">
                </c:if>
                <td>
                  <c:if test="${p.status == 1 }">有货</c:if>
                  <c:if test="${p.status == 0 }">无货</c:if>
                </td>
                <c:if test="${catalogId == 9 }">
                  <td>${p.brand }</td>
                </c:if>
                <c:if test="${catalogId != 9 }">
                  <td>
                    <a href="#" onmouseover="TagToTip('span${p.p_id }');" onmouseout="UnTip();"><img src="<%=basePath %>upload/${p.pic }" border="0" class="product_img"/></a>
                    <span id="span${p.p_id }">
                      <img src="<%=basePath %>upload/${p.pic }" width="196px" height="196px">
                    </span>
                  </td>
                  <td>${p.brand }</td>
                  <td>${p.type }</td>
                  <td>${p.spec }</td>
                  <td>${p.material }</td>
                </c:if>
                <td>${p.unit }</td>
                <c:if test="${sessionScope.xlf_planType == '4' }">
                <td>${p.price }</td>
                </c:if>
                <td>${p.productRemark }</td>
                <td>
                <c:if test="${p.status == 1 }">
                  <button class="btn btn-sm btn-primary" onclick="addToCar(${p.p_id});"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span>&nbsp;加入购物车</button>
                </c:if>
                <c:if test="${p.status == 0 }">
                  <button class="btn btn-sm btn-default" onclick="#" disabled="disabled"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span>&nbsp;加入购物车</button>
                </c:if>
                </td>
                </tr>
              </c:forEach>
            </tbody>
          </table>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-md-2 col-md-offset-5">
        共 ${pageRecord.totalRow } 条记录&nbsp;&nbsp;${pageRecord.pageNumber }/${pageRecord.totalPage }页
      </div>
      <div class="col-md-2 col-md-offset-3">
        <nav>
          <ul class="pagination">
            <c:if test="${pageRecord.totalPage <= 10 }">
              <c:set var="maxPage" value="${pageRecord.totalPage }"></c:set>
            </c:if>
            <c:if test="${pageRecord.totalPage > 10 }">
              <c:set var="maxPage" value="10"></c:set>
            </c:if>
            <c:forEach begin="1" end="${maxPage }" varStatus="s">
              <li><a href="/designer/chooseProduct?catalogId=${catalogId }&type=${type }&page=${s.index }">${s.index }</a></li>  
            </c:forEach>
          </ul>
        </nav>
      </div>
    </div>
    <div class="row">
      <div class="col-md-2 col-md-offset-5">
        <a class="btn btn-lg btn-block btn-default" href="/designer/plan" ><span class="glyphicon glyphicon-home" style="padding-right:10px;"></span>返回首页</a>
      </div>
    </div>
  </div>
  <!-- /container -->

  <script type="text/javascript">
			
		</script>
</body>

</html>